import { createRouter, createWebHistory ,RouterView  } from 'vue-router';
import HomeLogin from '../pages/HomeLogin.vue';
import HomeRegister from '../pages/HomeRegister.vue';
import AdminHomePage from '../pages/admin/AdminHomePage.vue';
import UserList from '../pages/admin/user/UserList.vue'; 
import Login from '../pages/admin/user/Login.vue';
import AddUser from '../pages/admin/user/AddUser.vue';
import DeviceList from '../pages/admin/device/DeviceList.vue'; 
import AddDevice from '../pages/admin/device/AddDevice.vue';
import RealData from '../pages/admin/device/RealData.vue';
import ControlDevice from '../pages/admin/device/ControlDevice.vue';
const routes = [
  {
    path: '/',
    name: 'home',
    component: AdminHomePage, 
    children: [
      {
        path: 'user', 
        component: RouterView,
        children: [
          {
            path: 'list',
            component: UserList,
            name: 'user-list'
          },
          {
            path: 'addUser',
            component: AddUser,
            name: 'user-add'
          },
          {
            path: 'login',
            component: Login,
            name: 'user-login'
          }
        ]
      },
      {
        path: 'device', 
        component: RouterView,
        children: [
          {
            path: 'list',
            component: DeviceList,
            name: 'device-list'
          },
          {
            path: 'add',
            component: AddDevice,
            name: 'device-add'
          },
          {
            path: 'realData',
            component: RealData,
            name: 'device-realdata'
          },
          {
            path: 'controlDevice',
            component: ControlDevice,
            name: 'device-controlDevice'
          },
          {
            path: '',
            component: DeviceList
          }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: HomeLogin
  },
  {
    path: '/register',
    name: 'register',
    component: HomeRegister
  },
  {
    path: '',
    redirect: '/login'
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

export default router;